package io.renren.modules.jxgk.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.DbFileEntity;
import io.renren.modules.jxgk.service.DbFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("DbFile/")
public class DbFileController {

    @Autowired
    DbFileService dbFileService;

    @RequestMapping("Select")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<DbFileEntity> cse = dbFileService.queryList(query);
        int total = dbFileService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(cse, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }
    @RequestMapping("/Delete")
    public R delete(@RequestBody String[] indexs){
        dbFileService.deleteBatch(indexs);
        return R.ok();
    }
    @RequestMapping("/Insert")
    public R save(@RequestBody DbFileEntity ste){
        dbFileService.save(ste);
        return R.ok();
    }
    @RequestMapping("/Info/{index}")
    public R info(@PathVariable("index") String index){
        DbFileEntity cse = dbFileService.queryObject(index);
        return R.ok().put("DbFile", cse);
    }
    @SysLog("修改用户")
    @RequestMapping("/Update")
    public R update(@RequestBody DbFileEntity cse){
        dbFileService.update(cse);
        return R.ok();
    }
    @RequestMapping("/Path/{index}")
    public R Path(@PathVariable("index") String index){
        List<String> cse= dbFileService.queryPath(index);
        return R.ok().put("DbFile2", cse);
    }

}